<!doctype html>
<html lang="en">

<head>
	<title>Home</title>
	{%include file="public/head_common" /%}
	<!-- Pager CSS -->
<link rel="stylesheet" href="__STATIC__/assets/css/plug.css">
<style type="text/css">
	table label{
		font-weight: bold;
		/*padding-right: 20px;*/
	}
	table span{
		margin-right:50px;
	}
	.pop{
		position: absolute;
		width: 300px;
		padding: 8px;
		background: #eee;
		box-shadow: 5px 5px 5px #888888;
		display: none;
	}
	.pop ul{
		list-style: none;
		overflow: hidden;
		padding: 0px;
	}
	.pop ul li{
		float: left;
		padding: 5px;
	}
	.pop ul li:hover{
		cursor: pointer;
		color: #00aaff
	}

	.table > tbody > tr > td{
		border-top:0px;
	}
	.table > tbody + tbody {
    	border-top: 1px solid #ddd;
	}
	.green{
		color: green;
		font-weight: bold;
	}
	.red{
		color: red;
		font-weight: bold;
	}
</style>
</head>

<body>
	<!-- MAIN -->
	<div class="main" id="app">
		<!-- MAIN CONTENT -->
		<div class="main-content">
			<ul class="breadcrumb">
			    <li>订单管理</li>
			    <li>换货订单</li>
			</ul>
			<div class="container-fluid">
				<div class="row" style="margin-bottom: 10px;">
					<form class="form-inline">
						<vue-select 
							placeholder="销售"
							v-model="search.acct_name"
							url="{%:url('Account/getSalers')%}"
							style="display: inline-block;width: 100px;">
						</vue-select>
						<input type="text" class="form-control" placeholder="客户" size="6" v-model="search.cust">
						<input type="text" class="form-control" placeholder="订单号" size="6" v-model="search.order_no">
						
					    <button type="button" class="btn btn-primary search" @click="getList()">查询</button>
					</form>
				</div>
				<!-- 数据开始-->
				<div class="row" id="result">
					<table class="table table-hover table-condensed">
						<thead>
							<tr>
								<th>登记日期</th>
								<th>订单号</th>
								<th>客户</th>
								<th>销售</th>
								
								<th>商品</th>
								<th>名称</th>
								<th>订单数量与尺码</th>
								<th>颜色</th>
								<th>单价</th>
								<th>换货数量</th>
								<th>换货原因</th>
								
								<th>处理状态</th>
								<th>物流信息</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							<tr v-for="item,i in rows">
								<td>{{ item.add_day }}
									<span style="font-size: 12px;color: #aaa">{{ item.add_time }}</span>
								</td>
								<td>{{ item.order_no }}</td>
								<td>{{ item.cust }}</td>
								<td>{{ item.saler }}</td>
								<td>
									<a :href="item.pic" target="_BLANK">
										<img :src="item.pic" height="38" class="pre_view">
									</a>
								</td>
								<td>{{ item.goods_name }}</td>
								<td>{{ item.order_qty }} * {{ item.spec }}</td>
								<td>{{ item.color }}</td>
								<td>{{ item.price }}</td>
								<td>{{ item.qty }}</td>
								<td>{{ item.reason }}</td>
								<td>
									<span :class="[item.exp_no == '' ? 'red' : 'green']">
									{{ item.exp_no == '' ? '待处理' : '已处理' }}</span>
								</td>
								<td>{{ item.exp_name }}<div>{{ item.exp_no }}</div></td>
								<td><a href="javascript:;" @click="registerExp(item)" v-if="!item.express_item_id">登记物流</a></td>
							</tr>
						</tbody>
					</table>
					<div>
						<vue-page :total_page='total_page' :cur_page='cur_page' @do-page='getList'></vue-page>
					</div>
				</div>
				<!-- 数据结束-->				
			</div>
		</div>
		<!-- END MAIN CONTENT -->
		<vue-modal :visible.sync="showModal" title="详情">
			<form class="form-horizontal" role="form" method="post" style="width: 90%;">
				<div class="form-group">
					<label for="lastname" class="col-sm-2 control-label">订单号/客户</label>
					<div class="col-sm-3 form-control-static">
						{{ express.order_no }} / {{ express.cust }}
					</div>
				</div>
				<div class="form-group">
					<label for="lastname" class="col-sm-2 control-label">商品</label>
					<div class="col-sm-3 form-control-static">
						{{ express.goods_name }}
					</div>
					<div class="col-sm-1"><img :src="express.pic" id="preview" height="220" style="position: absolute;"></div>
				</div>
				<div class="form-group">
					<label for="lastname" class="col-sm-2 control-label">换货原因</label>
					<div class="col-sm-3 form-control-static">
						{{ express.reason }}
					</div>
				</div>
				<div class="form-group">
					<label for="lastname" class="col-sm-2 control-label">物流公司</label>
					<div class="col-sm-2">
						<select class="form-control" v-model="express.name">
							<option value=""> - 选择 - </option>
							<option value="顺丰"> 顺丰 </option>
							<option value="圆通"> 圆通 </option>
							<option value="EMS"> EMS </option>
							<option value="京东"> 京东 </option>
							<option value="中通"> 中通 </option>
						</select>
					</div>
					
				</div>
				<div class="form-group">
					<label for="lastname" class="col-sm-2 control-label">物流单号</label>
					<div class="col-sm-2">
						<input type="text" class="form-control" v-model="express.express_no">
					</div>
				</div>
				<div class="form-group">
					<label for="lastname" class="col-sm-2 control-label">发货数量</label>
					<div class="col-sm-2">
						<input type="text" class="form-control" v-model="express.qty">
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-offset-2 col-sm-3">
						<button type="button" class="btn btn-primary" @click="registerExpHandle()">确定</button>
					</div>
				</div>
			</form>
		</vue-modal>
	</div>
	<!-- Javascript -->
	<script src="__STATIC__/assets/vendor/jquery/jquery.min.js"></script>
	<script src="__STATIC__/assets/vendor/vue.js"></script>
	<script src="__STATIC__/components/vue-page.js"></script>
	<script src="__STATIC__/components/vue-select.js"></script>
	<script src="__STATIC__/components/vue-modal.js"></script>
	<script src="__STATIC__/assets/vendor/layer-v3.1.1/layer/layer.js"></script>
	<script type="text/javascript">
		
		var vm = new Vue({
			el: '#app',
			data: {
				search:{
					acct_name: '',
					cust: '',
					order_no:''
				},
				rows: [],
				total_page: 0,
				cur_page: 1,
				progress_class: ['label-danger','label-primary','label-info','label-warning','label-success','red','orange'],
				showModal: false,
				express: {
				
				}
			},
			components: {
				'vue-page': vuePage,
				'vue-select': vueSelect,
				'vue-modal': vueModal
			},
			created: function(){
				this.getList();
				//console.log(this.rows);
			},
			methods:{
				getList: function(page=1){
					var data = {};
					data = this.search;
					data['progress'] = 6;
					var _this = this;
					$.ajax({
			            url: "{%:url('Orders/getChangeList')%}?page="+page,
			            type:'POST',
			            dataType: 'json',
			            data: data,
			            success:function(rsp){
			                _this.rows = rsp.data.rows;
			                _this.total_page = rsp.data.total_page;
							_this.cur_page = Number(rsp.data.page);
			            }
			        });
				},
				toItemDetail: function(id){
					this.showModal = true;
					var data = {
						id: id
					};
					var _this = this;
					$.post("{%:url('Orders/getItemInfo')%}",data,function(rsp){
						_this.info = rsp.data.info;
					},'json')
				},
				registerExp: function(item){
					this.express = {
						id: item.id,
						order_item_id: item.order_item_id,
						order_no: item.order_no,
						cust: item.cust,
						goods_name: item.goods_name,
						pic: item.pic,
						reason: item.reason,
						name: '',
						express_no: '',
						qty: ''
					};
					this.showModal = true;
				},
				registerExpHandle: function(){
					var data = this.express;
					var _this = this;
					$.post("{%:url('Express/changeExpHandle')%}",data,function(rsp){
						alert(rsp.msg)
						if (rsp.code) {
							_this.getList();
							_this.showModal = false;
						}
					},'json')
				}
			}
		});
		var tip_index;
		//鼠标事件
		$('table').on('mouseover','img.pre_view',function(){
			tip_index = layer.tips("<img src='"+$(this).attr('src')+"' height='220'>", this, {
				tips: [2, '#eee'],
				time: 0
			});
		}).on('mouseleave','img.pre_view',function(){
			layer.close(tip_index);
		})	
		
	</script>
</body>

</html>